<template>
	<view class="shadw-box u-flex u-col-center u-row-center" v-if="innerShow" @touchmove.stop.prevent="moveHandle">
		<view class="weui-half-screen-dialog" :style="{'border-color':mainColor}">
		    <view class="weui-half-screen-dialog__hd">
		        <text class="weui-half-screen-dialog__title">用户隐私保护提示</text>
		    </view>
		    <view class="weui-half-screen-dialog__bd">
		        <view class="weui-half-screen-dialog__tips">感谢您使用本小程序，您使用本小程序前应当阅读并同意</view>
		        <view class="weui-half-screen-dialog__tips" style="color:blue" @click="openPrivacyContract">《用户隐私保护指引》</view>
		        <view class="weui-half-screen-dialog__tips">当您点击同意并开始时用产品服务时，即表示您已理解并同意该条款内容，该条款将对您产生法律约束力。如您拒绝，将不能正常使用本小程序。</view>
		    </view>
		    <view class="weui-half-screen-dialog__ft">
		      <view class="weui-half-screen-dialog__btn-area">
		        <button
		          type="default"
		          @click="handleDisagree"
		        >不同意</button>
		        <button
		          type="default"
		          open-type="agreePrivacyAuthorization"
		          @agreeprivacyauthorization="handleAgree"
				  class="enter"
				  :style="{background:mainColor+'!important'}"
		        >同意并继续</button>
		      </view>
		    </view>
		  </view>
	</view>
	
</template>

<script>
	export default{
		name:"privacyPopup",
		props:{
			innerShow:{
				type:Boolean,
				default:false
			},
			mainColor:{
				type:String,
				default:'privacyPopup'
			}
		},
		data(){
			return{
				show:false
			}
		},
		methods:{
			moveHandle(){
				console.log('禁止触摸');
			},
			openPrivacyContract(){
				wx.openPrivacyContract({
					success: res => {
					  console.log('openPrivacyContract success')
					},
					fail: res => {
					  console.error('openPrivacyContract fail', res)
					}
				})
			},
			handleAgree(){
				uni.setStorage({
					key:'authorization',
					data:false
				})
				this.$emit('argee')
				this.close()
				console.log('用户同意了，哇啊哈哈哈')
			},
			handleDisagree(){
				uni.setStorage({
					key:'authorization',
					data:true
				})
				this.close()
				console.log('不同意，哇啊哈哈哈',this.innerShow)
			},
			close(){
				this.$emit('update:innerShow',false)
			}
		}
	}
</script>

<style>
	.shadw-box{
		position: fixed;
		top: 0;
		left:0;
		width:100%;
		height:100%;
		background-color:rgba(0, 0, 0, 0.65);
		z-index:9999;
	}
	.weui-half-screen-dialog{
		background-color:#fff;
		border-radius:20rpx;
		padding:20rpx 40rpx;
		width:75%;
		border:2px solid #DAB790;
		position: absolute;
		left:50%;
		top:50%;
		transform:translateX(-50%) translateY(-50%);
	}
	.weui-half-screen-dialog__title {
		 height:128rpx;
		 line-height:128rpx;
		 display: block;
		 color: #000;
		 font-weight: 500;
		 font-size: 30rpx;
	}
	.weui-half-screen-dialog__tips{
		padding-top:32rpx;
		color:#0000004D;
		font-size:28rpx;
	}
	.weui-half-screen-dialog__bd{
		padding-bottom: 76rpx;
	}
	.weui-half-screen-dialog__btn-area{
		display:flex;
		align-item:center;
		margin:0;
		bottom:0;
		padding-bottom: 40rpx;
	}
	.enter{
		color:#fff!important;
		background:#DAB790!important;
	}
	button {
		background-color: #f8f8f8;
		color: #000;
		-webkit-tap-highlight-color: transparent;
		background-color: #f8f8f8;
		border-radius: 5px;
		box-sizing: border-box;
		color: #000;
		cursor: pointer;
		display: block;
		font-size: 18px;
		line-height: 2.55555556;
		margin-left: auto;
		margin-right: auto;
		overflow: hidden;
		padding-left: 14px;
		padding-right: 14px;
		position: relative;
		text-align: center;
		text-decoration: none;
	}
</style>